function [error_sd_dev,model_emp_pdf] = sd_dev(sh_emp_q,sh_emp_hist_cats_q,pdf_hist_pts_data)


sh_emp_q = [sh_emp_q;1-sum(sh_emp_q)];

% Given the matrix of share of employment of each quality in different
% bins, and the sh of employment in different qualities, figure out the
% size distribution (histogram) in the model.
% model_emp_pdf = sum(sh_emp_hist_cats_q.*repmat(sh_emp_q,1,size(hist_pts,1)+1))';
model_emp_pdf = sh_emp_hist_cats_q'*sh_emp_q;

% Sum of squared errors - Disregard the last category which is a category
% like >5000. Also gives extra weight to the <5 category
% error_sd_dev = sum(100*(model_emp_pdf(1:end-1) - pdf_hist_pts_data(1:end-1)).^2);
error_sd_dev = sum(100*(model_emp_pdf(2:end-1) - pdf_hist_pts_data(2:end-1)).^2) + 10000*(model_emp_pdf(1) - pdf_hist_pts_data(1)).^2;


end
